//
//  ContentTVCell.m
//  星期一
//
//  Created by 来定MAC on 15/8/6.
//  Copyright (c) 2015年 LD. All rights reserved.
//

#import "ContentTVCell.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface ContentTVCell ()

@property (weak, nonatomic) IBOutlet UIImageView *content_imgV;
@property (weak, nonatomic) IBOutlet UILabel *praiseCount_L;
@property (weak, nonatomic) IBOutlet UILabel *addr_L;
@property (weak, nonatomic) IBOutlet UILabel *detail_L;
@property (weak, nonatomic) IBOutlet UIButton *praise_Btn;
@property (weak, nonatomic) IBOutlet UIButton *comment_Btn;
@property (weak, nonatomic) IBOutlet UIButton *share_Btn;
@property (weak, nonatomic) IBOutlet UILabel *style_L;

@end

@implementation ContentTVCell

- (instancetype)init
{
    self = [super init];
    if (self) {
        self = [[[NSBundle mainBundle] loadNibNamed:@"ContentTVCell" owner:nil options:nil] lastObject];
    }
    return self;
}
//准备接受载入的nib,xib文件
- (void)awakeFromNib {
    
    //NSLog(@"awake from nib");
}
//填充数据
- (void)setDateModel:(VenuseModel *)dateModel
{
    if (_dateModel != dateModel) {
        _dateModel = dateModel;
    }
    /*
     "id": 9836,
     "source": 0,
     "user": {
     "level": 1,
     "uid": 6497038,
     "nick": "Kim",
     "headFace": 12219151,
     "fashion": 0,
     "rcode": 1999,
     "laudCount": 0,
     "hasLauded": 0
     },
     "status": 10,
     "home": 1,
     "mid": 18979187,
     "commentCount": 7,
     "pubTime": 1438815600000,
     "descrp": "浅蓝色印花T恤搭配米色休闲裤，适合夏季出行。",
     "effectiveTime": 1438815781000,
     "amount": 0,
     "laudCount": 32,
     "auth": 0,
     "safe": 0,
     "venusDetails": 数组,
     "lauded": 0
     */
    [self.praiseCount_L setText:[NSString stringWithFormat:@"%ld人赞过",(long)self.dateModel.laudCount]];
    for (VenusDetailModel *detailModel in self.dateModel.venusDetails) {
        switch (detailModel.type) {
            case 3:
                [self.addr_L setText:detailModel.name];
                break;
            case 5:
                [self.style_L setText:[NSString stringWithFormat:@"#%@",detailModel.name]];
                break;
            default:
                break;
        }
    }
    //http://p1.ishecdn.com/m/18979187/300/0.png
    [self.content_imgV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://p1.ishecdn.com/m/%ld/300/0.png",(long)dateModel.mid]]];
    
    [self.detail_L setText:dateModel.descrp];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
//当需要立即进行视图刷新时调用
- (void)layoutIfNeeded
{
    [super layoutIfNeeded];
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
}

@end
